﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Handrise.CDCable.Mobile.Business
{
    /// <summary>
    /// 设备GPS服务
    /// </summary>
    public class DeviceGPSService
    {
        /// <summary>
        /// 更新设备GPS数据
        /// </summary>
        /// <param name="deviceGPSList"></param>
        /// <returns></returns>
        public void UpdateDeviceGPSList(List<DeviceGPS> deviceGPSList)
        {
            foreach (DeviceGPS deviceGPS in deviceGPSList)
            {
                if (AppLogic.dataService.Add<DeviceGPS>(deviceGPS) != 1)
                    AppLogic.dataService.Update<DeviceGPS>(deviceGPS);
            }
        }

        /// <summary>
        /// 获取设备GPS信息
        /// </summary>
        /// <param name="deviceGPSID"></param>
        /// <returns></returns>
        public DeviceGPS GetDeviceGPS(string deviceGPSID)
        {
            return AppLogic.dataService.GetEntityByKey<DeviceGPS>(deviceGPSID);
        }

        /// <summary>
        /// 通过设备ID获取设备ＧＰＳ信息
        /// </summary>
        /// <param name="deviceCode"></param>
        /// <returns></returns>
        public DeviceGPS GetDeviceGPSByDeviceCode(string deviceCode)
        {
            return AppLogic.dataService.GetFirstEntity<DeviceGPS>("DeviceCode = '" + deviceCode + "'", "");
        }


    }
}
